using System;
using System.Collections.Generic;
using System.ServiceModel.Description;
using System.Text;

namespace PSE.Framework.Service.Security.Services
{
    /// <summary>
    /// Indicates whether a method call should be impersonated.
    /// </summary>
    [AttributeUsage(AttributeTargets.Method)]
    public sealed class ImpersonationAttribute : Attribute, IOperationBehavior
    {
        #region Public Methods

        #region IOperationBehavior Members

        /// <summary>
        /// 
        /// </summary>
        /// <param name="operationDescription"></param>
        /// <param name="bindingParameters"></param>
        public void AddBindingParameters(OperationDescription operationDescription, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="operationDescription"></param>
        /// <param name="clientOperation"></param>
        public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="operationDescription"></param>
        /// <param name="dispatchOperation"></param>
        public void ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
        {
            if (dispatchOperation == null)
            {
                throw new ArgumentNullException("dispatchOperation");
            }
            dispatchOperation.Invoker = new ServiceImpersonationInvoker(dispatchOperation.Invoker);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="operationDescription"></param>
        public void Validate(OperationDescription operationDescription)
        {
        }

        #endregion

        #endregion
    }
}
